package com.ikan.positionserver.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum PackageTypeEnum {
    DHCPDISCOVER(1, "DHCPDISCOVER"),
    DHCPOFFER(2, "DHCPOFFER"),
    DHCPREQUEST(3, "DHCPREQUEST"),
    DHCPDECLINE(4, "DHCPDECLINE"),
    DHCPACK(5, "DHCPACK"),
    DHCPNAK(6, "DHCPNAK"),
    DHCPRELEASE(7, "DHCPRELEASE"),
    DHCPINFORM(8, "DHCPINFORM"),
    DHCPFORCERENEW(9, "DHCPFORCERENEW"),
    DHCPLEASEQUERY(10, "DHCPLEASEQUERY"),
    DHCPLEASEUNASSIGNED(11, "DHCPLEASEUNASSIGNED"),
    DHCPLEASEUNKNOWN(12, "DHCPLEASEUNKNOWN"),
    DHCPLEASEACTIVE(13, "DHCPLEASEACTIVE"),

    ;
    //编码
    private int code;
    //描述
    private String desc;

    /***
     * 根据编码来获取枚举值
     * @param code
     * @return
     */
    public static final PackageTypeEnum getByCode(int code) {
        for (PackageTypeEnum tmpEnum : values()) {
            if (tmpEnum.getCode() == code) {
                return tmpEnum;
            }
        }
        return null;
    }
}
